package javamusic.Servlet.Sala;

import java.io.IOException;

import javamusic.excepcion.DAOExcepcion;
import javamusic.negocio.GestionSala;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class ServletSalaModificar
 */
@WebServlet("/ServletSalaModificar")
public class ServletSalaModificar extends HttpServlet {
	private static final long serialVersionUID = 1L;

    /**
     * Default constructor. 
     */
    public ServletSalaModificar() {
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String idsala1 = request.getParameter("idsala");
		int idsala = Integer.parseInt(idsala1);
		String nombre = request.getParameter("nombre");
		String capacidad1 = request.getParameter("capacidad");
		int capacidad = Integer.parseInt(capacidad1);
		String descripcion = request.getParameter("descripcion");
				String elog1 = request.getParameter("elog");
		int elog = Integer.parseInt(elog1);
		
		
		//String idlocal1 = request.getParameter("idlocal");
		//int idlocal = Integer.parseInt(idlocal1);
		try {
			GestionSala negocio = new GestionSala();
			negocio.actualizar(idsala, nombre, capacidad, descripcion, elog);
		
			response.sendRedirect(request.getContextPath()	+ "/ServletSalaBuscar");
		} catch (DAOExcepcion e) {
			System.out.println(e.getMessage());
			RequestDispatcher rd = request.getRequestDispatcher("error.jsp");
			rd.forward(request, response);
		}
		
	}

}
